package com.todo.strategy.online.iface.request;

import com.todo.common.common.entity.CurrentUser;
import com.todo.common.common.enums.BizErrorCodeEnum;
import com.todo.common.common.exception.BizException;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Date;

/**
 * @author azhebuxing
 * @date 2024/5/9 16:37
 * @description
 */
@Data
@Schema(title = "更新计划集合入参", description = "更新计划集合入参")
public class UpdatePlanSetParam {

    private CurrentUser _user;

    @Schema(title = "集合id", description = "集合id")
    private Long planId;

    @Schema(title = "标题", description = "标题")
    private String title;

    @Schema(title = "描述", description = "描述")
    private String desc;

    @Schema(title = "主图", description = "主图")
    private String mainImg;

    @Schema(title = "计划开始时间", description = "计划开始时间")
    private Date startPlanTime;

    @Schema(title = "计划结束时间", description = "计划结束时间")
    private Date endPlanTime;

    @Schema(title = "计划城市", description = "计划城市")
    private String planCity;

    @Schema(title = "是否私有", description = "是否私有")
    private Integer isPrivate;

    @Schema(title = "预计花费/元", description = "预计花费/元")
    private Integer planMoneySpend;

    @Schema(title = "计划类型", description = "计划类型")
    private Integer planType;

    @Schema(title = "是否出行", description = "是否出行")
    private Integer isTravel;

    public boolean baseCheck() {
        if (planId == null || title == null || desc == null || planCity == null || planType == null || mainImg == null || startPlanTime == null || endPlanTime == null || isPrivate == null) {
            return false;
        }
        if (startPlanTime.after(endPlanTime)) {
            throw new BizException(BizErrorCodeEnum.PARAM_ERROR, "开始时间不能大于结束时间");
        }
        return true;
    }
}
